﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class CtrMovie
{
    private DBMovie dbm = new DBMovie();
    private DBShowTime dbs = new DBShowTime();
    private CtrShowTime cts = new CtrShowTime();

    public List<Movie> Read(string title)
    {
        return dbm.Read(title);
    }
    public Movie Read(int id)
    {
        return dbm.Read(id);
    }
    public List<Movie> ReadAll()
    {
        return dbm.ReadAll();
    }
    public int Insert(Movie movie)
    {
        return dbm.Insert(movie);
    }
    public int Update(Movie movie)
    {
        return dbm.Update(movie);
    }
    public int Delete(int id)
    {
        return dbm.Delete(id);
    }
    public List<Movie> DateMovie(String date)
    {
        DateTime dt = Convert.ToDateTime(date);
        List<ShowTime> show = cts.Read(dt);
        List<Movie> mov = new List<Movie>();
        //List<Movie> givenDateShowTime = new List<Movie>();
        //date.ToString("yyyy/mm/dd");
        //string currentDate = DateTime.Today.ToString("yyyy/mm/dd");
        
        foreach (ShowTime item in show)
        {
                Movie movie = dbm.Read(item.Movie.Id);
                movie.Time = item.DateTime.ToShortTimeString();
                movie.ShowTimeID = item.ID;
                
                mov.Add(movie);
                
            
        }

        return mov;
    }

    public Movie MovieObject(int id, string title, string description, double price, bool is3d, int length, int commercials, int trailer, string image)
    {
        Movie mov = new Movie(title, description, price, is3d, length, commercials, trailer, image);
        mov.Id = id;
        return mov;
    }


}

